package com.ly.user_system.base;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ly.user_system.common.PageResult;

import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * 基础服务类
 *
 * @param <DTO>
 */
public interface BaseService<Entity, DTO, Detail, PQuery extends PageQuery> {



    Boolean saveBatch(List<DTO> dtoList);

    Boolean saveBatch(List<DTO> dtoList, Consumer<List<Entity>> entityConsumer);

    PageResult<DTO> page(PQuery query);

    Boolean deleteBatch(List<Long> ids);

    Boolean deleteBatch(List<Long> ids,Consumer<List<Long>> checkConsumer);

    Boolean update(DTO dto);

    Boolean batchUpdate(List<DTO> list);

    DTO getById(Long id);

    List<DTO> getByIds(List<Long> ids);

    Detail detailById(Long id);

    List<DTO> listDtoWithConsumer(Consumer<LambdaQueryWrapper<Entity>> queryWrapperConsumer, Function<List<DTO>,List<DTO>> function);

    <T> T queryEntityWithFunction(Consumer<LambdaQueryWrapper<Entity>> queryWrapperConsumer, Function<Entity, T> function);

    Entity queryEntity(Consumer<LambdaQueryWrapper<Entity>> queryWrapperConsumer);

    List<Entity> listEntity(Consumer<LambdaQueryWrapper<Entity>> queryWrapperConsumer);

    <T> List<T> listEntityWithFunction(Consumer<LambdaQueryWrapper<Entity>> queryWrapperConsumer, Function<Entity, T> function);

     List<DTO> list(DTO dto);



}
